package xin.yangshuai.generator01.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xin.yangshuai.generator01.entity.ModuleInfo;
import xin.yangshuai.generator01.service.GeneratorService;
import xin.yangshuai.generator01.service.ModuleService;

import java.util.List;

/**
 * IndexController
 *
 * @author shuai
 * @date 2024/10/17
 */
@RestController
public class IndexController {

    @Autowired
    private GeneratorService generatorService;

    @Autowired
    private ModuleService moduleService;

    @RequestMapping
    public String index() {
        return "hello world generator";
    }

    @GetMapping("create")
    private String create(String moduleName) {
        generatorService.create(moduleName);
        return "hello world";
    }

    @GetMapping("list")
    private List<ModuleInfo> list() {
        return moduleService.list();
    }

    @GetMapping("maxPort")
    private int maxPort() {
        return moduleService.maxPort();
    }

    @GetMapping("writeMd")
    private String writeMd() {
        moduleService.writeMd();
        return "hello world";
    }
}
